<!DOCTYPE html>
<html lang="zh-Hans">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 6.2.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/vhuichen.ico">
  <link rel="icon" type="image/png" sizes="32x32" href="/vhuichen.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/vhuichen.ico">
  <link rel="mask-icon" href="/vhuichen.ico" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha256-AbA177XfpSnFEvgpYu1jMygiLabzPCJCRIBtR5jGc0k=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"vhuichen.github.io","root":"/","images":"/images","scheme":"Pisces","darkmode":false,"version":"8.13.0","exturl":false,"sidebar":{"position":"left","display":"display","padding":18,"offset":12},"copycode":{"enable":false,"style":null},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"Searching...","empty":"We didn't find any results for the search: ${query}","hits_time":"${hits} results found in ${time} ms","hits":"${hits} results found"}}</script><script src="/js/config.js"></script>

    <meta property="og:type" content="website">
<meta property="og:title" content="vhuichen">
<meta property="og:url" content="https://vhuichen.github.io/page/9/index.html">
<meta property="og:site_name" content="vhuichen">
<meta property="og:locale">
<meta property="article:author" content="vhuichen">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="https://vhuichen.github.io/page/9/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":true,"isPost":false,"lang":"zh-Hans","comments":"","permalink":"","path":"page/9/index.html","title":""}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>vhuichen</title>
  






  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">vhuichen</h1>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">记录、分享</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section">Home</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section">Archives</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section">About</a></li>
  </ul>
</nav>




</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-overview-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="vhuichen"
      src="/images/vhuichen.jpg">
  <p class="site-author-name" itemprop="name">vhuichen</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">78</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">11</span>
        <span class="site-state-item-name">categories</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">86</span>
        <span class="site-state-item-name">tags</span></a>
      </div>
  </nav>
</div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="Back to top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner index posts-expand">

    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="https://vhuichen.github.io/2017/07/2017/07/iOS%E5%BC%80%E5%8F%91%E4%B9%8B%E5%88%A4%E6%96%ADView%E6%98%AF%E5%90%A6%E6%98%BE%E7%A4%BA%E5%9C%A8%E5%BD%93%E5%89%8D%E7%AA%97%E5%8F%A3/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/vhuichen.jpg">
      <meta itemprop="name" content="vhuichen">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="vhuichen">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="undefined | vhuichen">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2017/07/2017/07/iOS%E5%BC%80%E5%8F%91%E4%B9%8B%E5%88%A4%E6%96%ADView%E6%98%AF%E5%90%A6%E6%98%BE%E7%A4%BA%E5%9C%A8%E5%BD%93%E5%89%8D%E7%AA%97%E5%8F%A3/" class="post-title-link" itemprop="url">iOS开发之判断View是否显示在当前窗口</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2017-07-11 21:01:43" itemprop="dateCreated datePublished" datetime="2017-07-11T21:01:43+08:00">2017-07-11</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">Edited on</span>
      <time title="Modified: 2018-07-01 16:07:46" itemprop="dateModified" datetime="2018-07-01T16:07:46+08:00">2018-07-01</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">In</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/iOS%E5%9F%BA%E7%A1%80/" itemprop="url" rel="index"><span itemprop="name">iOS基础</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h3 id="判断View是否显示在当前窗口"><a href="#判断View是否显示在当前窗口" class="headerlink" title="判断View是否显示在当前窗口"></a>判断View是否显示在当前窗口</h3><p>写一个分类</p>
<figure class="highlight objc"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#import <span class="string">&lt;UIKit/UIKit.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">@interface</span> <span class="title">UIView</span> (<span class="title">VCHFrame</span>)</span></span><br><span class="line"></span><br><span class="line">- (<span class="type">BOOL</span>)isShowingOnKeyWindow;</span><br><span class="line"></span><br><span class="line"><span class="keyword">@end</span></span><br></pre></td></tr></table></figure>

<figure class="highlight objc"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">- (<span class="type">BOOL</span>)isShowingOnKeyWindow &#123;</span><br><span class="line">    <span class="built_in">UIWindow</span> *window = [<span class="built_in">UIApplication</span> sharedApplication].keyWindow;</span><br><span class="line">    <span class="built_in">CGRect</span> newRect = [window convertRect:<span class="keyword">self</span>.frame fromView:<span class="keyword">self</span>.superview];</span><br><span class="line">    <span class="type">BOOL</span> intersects = <span class="built_in">CGRectIntersectsRect</span>(newRect, window.bounds);</span><br><span class="line">    <span class="keyword">return</span> intersects &amp;&amp; !<span class="keyword">self</span>.isHidden &amp;&amp; (<span class="keyword">self</span>.alpha &gt; <span class="number">0.01</span>) &amp;&amp; (<span class="keyword">self</span>.window == window);</span><br><span class="line">&#125;</span><br><span class="line">~~~   </span><br><span class="line"></span><br><span class="line">### 判断控制器是否显示到当前窗口   </span><br><span class="line">可以用一种简单的方法，判断view是否已经加载，再判断window是否存在。用这两个条件正常情况下都可以判断出来。   </span><br><span class="line">**这种方法不是绝对的。**</span><br><span class="line"></span><br><span class="line">~~~ objc</span><br><span class="line">- (<span class="type">BOOL</span>)isShowing &#123;</span><br><span class="line">	<span class="keyword">return</span> <span class="keyword">self</span>.isViewLoaded &amp;&amp; <span class="keyword">self</span>.view.window;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="坐标转变方法"><a href="#坐标转变方法" class="headerlink" title="坐标转变方法"></a>坐标转变方法</h3><pre><code class="objc">CGRect newRect = [view1 convertRect:view2.frame toView:view3];
CGRect newRect = [view3 convertRect:view2.frame fromView:view1];
</code></pre>
<p>view1：view2的父类（view2的frame相对的坐标系的view）<br>view2：需要转换坐标的view<br>view3：转换后坐标所在的view   </p>

      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="https://vhuichen.github.io/2017/06/2017/06/iOS%E5%BC%80%E5%8F%91%E4%B9%8B%E4%B8%8A%E4%BC%A0%E4%BB%A3%E7%A0%81%E5%88%B0CocoaPods/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/vhuichen.jpg">
      <meta itemprop="name" content="vhuichen">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="vhuichen">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="undefined | vhuichen">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2017/06/2017/06/iOS%E5%BC%80%E5%8F%91%E4%B9%8B%E4%B8%8A%E4%BC%A0%E4%BB%A3%E7%A0%81%E5%88%B0CocoaPods/" class="post-title-link" itemprop="url">iOS开发之上传代码到CocoaPods</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2017-06-26 19:54:23" itemprop="dateCreated datePublished" datetime="2017-06-26T19:54:23+08:00">2017-06-26</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">Edited on</span>
      <time title="Modified: 2018-07-01 16:07:17" itemprop="dateModified" datetime="2018-07-01T16:07:17+08:00">2018-07-01</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">In</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/iOS%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">iOS开发</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>学习下怎样将自己的代码上传到CocoaPods</p>
<h2 id="1-在GitHub上创建新的仓库，并clone到本地"><a href="#1-在GitHub上创建新的仓库，并clone到本地" class="headerlink" title="1.在GitHub上创建新的仓库，并clone到本地"></a>1.在GitHub上创建新的仓库，并clone到本地</h2><p>此时将库文件但放到一个单独的文件夹内，并将相关的演示Demo写好。</p>
<h2 id="2-创建podspec文件"><a href="#2-创建podspec文件" class="headerlink" title="2.创建podspec文件"></a>2.创建podspec文件</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd path****</span><br><span class="line">pod spec create VCHKit</span><br></pre></td></tr></table></figure>

<h2 id="3-修改podspec文件"><a href="#3-修改podspec文件" class="headerlink" title="3.修改podspec文件"></a>3.修改podspec文件</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">s.name         = &quot;VCHKit&quot;</span><br><span class="line">s.version      = &quot;0.0.1&quot;</span><br><span class="line">s.summary      = &quot;this is summary&quot;</span><br><span class="line">s.description  = &lt;&lt;-DESC</span><br><span class="line">                 this is description</span><br><span class="line">                 DESC</span><br><span class="line">s.homepage     = &quot;https://github.com/vhuichen/VCHKit&quot;</span><br><span class="line">s.license      = &quot;MIT&quot;</span><br><span class="line">s.author       = &#123; &quot;vhuichen&quot; =&gt; &quot;vhuichen@163.com&quot; &#125;</span><br><span class="line">s.platform     = :ios, &quot;8.0&quot;</span><br><span class="line">s.source       = &#123; :git =&gt; &quot;https://github.com/vhuichen/VCHKit.git&quot;, :tag =&gt; &quot;#&#123;s.version&#125;&quot; &#125;</span><br><span class="line">s.source_files  = &quot;VCHMapKit/*.&#123;h,m&#125;&quot;, &quot;VCHMapKit/XXXX/*.&#123;h,m&#125;&quot;</span><br><span class="line">s.frameworks = &quot;UIKit&quot;</span><br><span class="line">s.requires_arc = true</span><br></pre></td></tr></table></figure>
<p>*注意：描述description必须填写，并且不能和summary相同</p>
<h3 id="验证pod"><a href="#验证pod" class="headerlink" title="验证pod"></a>验证pod</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pod lib lint</span><br></pre></td></tr></table></figure>
<p>如果验证成功则会显示成功信息<br>–<strong>VCHMapKit passed validation.</strong></p>
<h2 id="4-提交库到CocoaPods-trunk"><a href="#4-提交库到CocoaPods-trunk" class="headerlink" title="4.提交库到CocoaPods trunk"></a>4.提交库到CocoaPods trunk</h2><h3 id="如果没有注册，则先注册trunk"><a href="#如果没有注册，则先注册trunk" class="headerlink" title="如果没有注册，则先注册trunk"></a>如果没有注册，则先注册trunk</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pod trunk register vhuichen@163.com &#x27;vhuichen&#x27;  --verbose</span><br></pre></td></tr></table></figure>

<h3 id="向trunk服务器查询自己的注册信息"><a href="#向trunk服务器查询自己的注册信息" class="headerlink" title="向trunk服务器查询自己的注册信息"></a>向trunk服务器查询自己的注册信息</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pod trunk me</span><br></pre></td></tr></table></figure>

<h3 id="打上和GitHub上相同的tag"><a href="#打上和GitHub上相同的tag" class="headerlink" title="打上和GitHub上相同的tag"></a>打上和GitHub上相同的tag</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">set the new version to 0.0.1</span><br><span class="line">set the new tag to 0.0.1</span><br></pre></td></tr></table></figure>

<h2 id="5-提交代码到GitHub"><a href="#5-提交代码到GitHub" class="headerlink" title="5.提交代码到GitHub"></a>5.提交代码到GitHub</h2><p>将代码提交到GitHub后，再打上tag   </p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git tag 0.0.1   </span><br><span class="line">git push --tags</span><br></pre></td></tr></table></figure>

<h2 id="6-上传或更新trunk"><a href="#6-上传或更新trunk" class="headerlink" title="6.上传或更新trunk"></a>6.上传或更新trunk</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pod trunk push</span><br></pre></td></tr></table></figure>

<h2 id="7-出现的问题"><a href="#7-出现的问题" class="headerlink" title="7.出现的问题"></a>7.出现的问题</h2><p><strong>1、Unable to find a pod with name, author, summary, or description matching <code>VCHMapKit</code></strong>	<br>解决方法，先删除缓存，然后在重新搜索</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">rm ~/Library/Caches/CocoaPods/search_index.json</span><br><span class="line">pod search VCHMapKit</span><br></pre></td></tr></table></figure>










      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="https://vhuichen.github.io/2017/05/2017/05/iOS%E5%BC%80%E5%8F%91%E4%B9%8BOC%E9%A1%B9%E7%9B%AE%E6%B7%B7%E7%BC%96Swift%E9%81%87%E5%88%B0%E7%9A%84%E4%B8%80%E4%B8%AA%E5%9D%91/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/vhuichen.jpg">
      <meta itemprop="name" content="vhuichen">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="vhuichen">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="undefined | vhuichen">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2017/05/2017/05/iOS%E5%BC%80%E5%8F%91%E4%B9%8BOC%E9%A1%B9%E7%9B%AE%E6%B7%B7%E7%BC%96Swift%E9%81%87%E5%88%B0%E7%9A%84%E4%B8%80%E4%B8%AA%E5%9D%91/" class="post-title-link" itemprop="url">iOS开发之OC项目混编Swift遇到的一个坑</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2017-05-23 22:12:31" itemprop="dateCreated datePublished" datetime="2017-05-23T22:12:31+08:00">2017-05-23</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">Edited on</span>
      <time title="Modified: 2021-04-18 20:36:10" itemprop="dateModified" datetime="2021-04-18T20:36:10+08:00">2021-04-18</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">In</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/iOS%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">iOS开发</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>这个问题花了我2天的时间没解决，记下来！</p>
<h2 id="项目需求"><a href="#项目需求" class="headerlink" title="项目需求"></a>项目需求</h2><p>由于项目需要定制化，需要在原来的项目上修改部分图片以及部分接口，然后上一个新的APP。于是想到用Target来实现。copy一个新的Target。<br><img src="http://ovsbvt5li.bkt.clouddn.com/17-11-12/5962422.jpg"></p>
<p><strong>编译后，发现旧的Target编译成功，而新创建的Target编译失败。</strong><br>报错提示：</p>
<blockquote>
<p><strong>Command failed due to signal: Segmentation fault: 11</strong>     </p>
</blockquote>
<p>在文件上方提示：</p>
<blockquote>
<p><strong>An internal error occurred.Editing functionality may be limited</strong><br><strong>An internal error occurred. Soucre Editor functionality is limited,Attempting to restore</strong>			</p>
</blockquote>
<p><img src="http://ovsbvt5li.bkt.clouddn.com/17-11-12/21764291.jpg"></p>
<p><strong>Xcode版本:8.3.3</strong></p>
<h3 id="解决方法"><a href="#解决方法" class="headerlink" title="解决方法"></a>解决方法</h3><blockquote>
<p>rm -rf ~&#x2F;Library&#x2F;Developer&#x2F;Xcode&#x2F;DerivedData&#x2F;   </p>
</blockquote>
<p>或者   </p>
<blockquote>
<p>Xcode –&gt; Preferences –&gt; Location –&gt; DerivedData  </p>
</blockquote>
<p>点进路径链接后，删除里面的所有内容</p>
<p>使用上面的方法可以解决问题，但是。。。。<br>当我修改了Swift的代码后问题又出现了同样的问题（Swift类中添加一个新的空函数），编译报错：   </p>
<blockquote>
<p><strong>Command failed due to signal: Segmentation fault: 11</strong>   </p>
</blockquote>
<p>但这种情况只有copy的Target会出现，原来的Target编译通过，代码是没有问题的，只能重新删除DerivedData里面的数据</p>
<h3 id="相关连接"><a href="#相关连接" class="headerlink" title="相关连接"></a>相关连接</h3><p><a target="_blank" rel="noopener" href="https://stackoverflow.com/questions/33456411/ios-project-showing-error-an-internal-error-occurred-editing-functionality-may"><strong>stackoverflow相关问题</strong></a><br> 但是很遗憾无法从根本上解决这个问题</p>
<h3 id="总之"><a href="#总之" class="headerlink" title="总之"></a>总之</h3><p>这是一个奇葩的问题<br>1、为什么旧的Target没有问题，新的Target就有问题？<br>2、多个Target下 <strong>Objective-C Generated Interface Header Name</strong> 中设置的名称要不要一样，如果一样的话，是不是对应同一个文件？<br>3、为什么修改了Swift文件后，编译出错？（语法没问题）</p>

      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="https://vhuichen.github.io/2017/05/2017/05/iOS%E5%9F%BA%E7%A1%80%E4%B9%8B%E7%90%86%E8%A7%A3NSNumericSearch/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/vhuichen.jpg">
      <meta itemprop="name" content="vhuichen">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="vhuichen">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="undefined | vhuichen">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2017/05/2017/05/iOS%E5%9F%BA%E7%A1%80%E4%B9%8B%E7%90%86%E8%A7%A3NSNumericSearch/" class="post-title-link" itemprop="url">iOS基础之理解NSNumericSearch</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2017-05-19 21:51:32" itemprop="dateCreated datePublished" datetime="2017-05-19T21:51:32+08:00">2017-05-19</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">Edited on</span>
      <time title="Modified: 2018-07-01 16:06:50" itemprop="dateModified" datetime="2018-07-01T16:06:50+08:00">2018-07-01</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">In</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/iOS%E5%9F%BA%E7%A1%80/" itemprop="url" rel="index"><span itemprop="name">iOS基础</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>项目有个需求，比较两个字符串的大小，百度一下发现这个方法，记录下来！</p>
<h2 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h2><p>方法名   </p>
<figure class="highlight objc"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">- (<span class="built_in">NSComparisonResult</span>)compare:(<span class="built_in">NSString</span> *)string options:(<span class="built_in">NSStringCompareOptions</span>)mask;</span><br></pre></td></tr></table></figure>

<p>代码实现：  </p>
<figure class="highlight objc"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="built_in">NSString</span> *str0 = <span class="string">@&quot;F0FF23FF&quot;</span>;</span><br><span class="line"><span class="built_in">NSString</span> *str1 = <span class="string">@&quot;F0FF023FF&quot;</span>;</span><br><span class="line"><span class="built_in">NSLog</span>(<span class="string">@&quot;%@ compare %@ == %zd&quot;</span>, str0, str1, [str0 compare:str1 options:<span class="built_in">NSNumericSearch</span>]);</span><br><span class="line"><span class="comment">//log : F0FF23FF compare F0FF023FF == 0</span></span><br><span class="line"><span class="comment">//理解：compare方法内部可以理解为把两个字符串拆分成</span></span><br><span class="line"><span class="comment">//F0FF23FF  --&gt; F 0 FF  23 FF</span></span><br><span class="line"><span class="comment">//F0FF023FF --&gt; F 0 FF 023 FF</span></span><br><span class="line"><span class="comment">//结果等于:0(两者相等)</span></span><br><span class="line"><span class="comment">//说明这个方法会将相邻的数字当成一个整体</span></span><br><span class="line"></span><br><span class="line">str0 = <span class="string">@&quot;E0FF23FF&quot;</span>;</span><br><span class="line">str1 = <span class="string">@&quot;F0FF23FF&quot;</span>;</span><br><span class="line"><span class="built_in">NSLog</span>(<span class="string">@&quot;%@ compare %@ == %zd&quot;</span>, str0, str1, [str0 compare:str1 options:<span class="built_in">NSNumericSearch</span>]);</span><br><span class="line"><span class="comment">//log : E0FF23FF compare F0FF23FF == -1</span></span><br><span class="line"><span class="comment">//理解：compare方法内部可以理解为把两个字符串拆分成</span></span><br><span class="line"><span class="comment">//E0FF23FF --&gt; E 0 FF 23 FF</span></span><br><span class="line"><span class="comment">//F0FF23FF --&gt; F 0 FF 23 FF</span></span><br><span class="line"><span class="comment">// E &lt; F , 结果等于:-1(前者小于后者)</span></span><br><span class="line"><span class="comment">//说明非数字也会进行比较</span></span><br><span class="line"></span><br><span class="line">str0 = <span class="string">@&quot;EF0FF23FF&quot;</span>;</span><br><span class="line">str1 = <span class="string">@&quot;F0FF23FF&quot;</span>;</span><br><span class="line"><span class="built_in">NSLog</span>(<span class="string">@&quot;%@ compare %@ == %zd&quot;</span>, str0, str1, [str0 compare:str1 options:<span class="built_in">NSNumericSearch</span>]);</span><br><span class="line"><span class="comment">//log : EF0FF23FF compare F0FF23FF == -1</span></span><br><span class="line"><span class="comment">//理解：compare方法内部可以理解为把两个字符串拆分成</span></span><br><span class="line"><span class="comment">//EF0FF23FF --&gt; EF 0 FF 23 FF</span></span><br><span class="line"><span class="comment">//F0FF23FF  --&gt; F  0 FF 23 FF</span></span><br><span class="line"><span class="comment">//从左到右进行比较，E &lt; F , 结果等于:-1(前者小于后者)</span></span><br><span class="line"><span class="comment">//说明此处是将&quot;EF&quot;中的&quot;E&quot; 和 &quot;F&quot; 比较，非数字不当成一个整体</span></span><br><span class="line"></span><br><span class="line">str0 = <span class="string">@&quot;E1FF23FF&quot;</span>;</span><br><span class="line">str1 = <span class="string">@&quot;F0FF23FF&quot;</span>;</span><br><span class="line"><span class="built_in">NSLog</span>(<span class="string">@&quot;%@ compare %@ == %zd&quot;</span>, str0, str1, [str0 compare:str1 options:<span class="built_in">NSNumericSearch</span>]);</span><br><span class="line"><span class="comment">//log : E1FF23FF compare F0FF23FF == -1</span></span><br><span class="line"><span class="comment">//理解：compare方法内部可以理解为把两个字符串拆分成</span></span><br><span class="line"><span class="comment">//E0FF23FF --&gt; E 1 FF 23 FF</span></span><br><span class="line"><span class="comment">//F0FF23FF --&gt; F 0 FF 23 FF</span></span><br><span class="line"><span class="comment">//说明从左到右开始判断，数字有没优先权</span></span><br><span class="line"></span><br><span class="line">str0 = <span class="string">@&quot;1&quot;</span>;</span><br><span class="line">str1 = <span class="string">@&quot;.1&quot;</span>;</span><br><span class="line"><span class="built_in">NSLog</span>(<span class="string">@&quot;%@ compare %@ == %zd&quot;</span>, str0, str1, [str0 compare:str1 options:<span class="built_in">NSNumericSearch</span>]);</span><br><span class="line"><span class="comment">//log : 1 compare .1 == 1</span></span><br><span class="line"><span class="comment">//理解：compare方法内部可以理解为把两个字符串拆分成</span></span><br><span class="line"><span class="comment">//1 --&gt;  0 1</span></span><br><span class="line"><span class="comment">//.1 --&gt; . 1</span></span><br><span class="line"><span class="comment">//空格处应该不补充了一个数字，&quot;.&quot;的ASCII码小于补充数字0的ASCII码。结果等于:1(前者大于后者)</span></span><br><span class="line"></span><br><span class="line">str0 = <span class="string">@&quot;1&quot;</span>;</span><br><span class="line">str1 = <span class="string">@&quot;:1&quot;</span>;</span><br><span class="line"><span class="built_in">NSLog</span>(<span class="string">@&quot;%@ compare %@ == %zd&quot;</span>, str0, str1, [str0 compare:str1 options:<span class="built_in">NSNumericSearch</span>]);</span><br><span class="line"><span class="comment">//log : 1 compare :1 == -1</span></span><br><span class="line"><span class="comment">//1 --&gt;  0 1</span></span><br><span class="line"><span class="comment">//.1 --&gt; : 1</span></span><br><span class="line"><span class="comment">//空格处应该不补充了一个数字，&quot;:&quot;的ASCII码大于补充数字0的ASCII码。结果等于:-1(前者小于后者)</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>NSNumericSearch options 会将相邻数字作为一个整体，然后两个字符串的数字整体左对齐，首位补0后进行比较。<br>(以上结论纯属个人理解🙂)</p>

      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="https://vhuichen.github.io/2017/01/2017/01/iOS%E5%9F%BA%E7%A1%80%E4%B9%8BnavigationItem.title%E8%AE%BE%E7%BD%AE%E4%BD%86%E4%B8%8D%E6%98%BE%E7%A4%BA/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/vhuichen.jpg">
      <meta itemprop="name" content="vhuichen">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="vhuichen">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="undefined | vhuichen">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2017/01/2017/01/iOS%E5%9F%BA%E7%A1%80%E4%B9%8BnavigationItem.title%E8%AE%BE%E7%BD%AE%E4%BD%86%E4%B8%8D%E6%98%BE%E7%A4%BA/" class="post-title-link" itemprop="url">iOS基础之navigationItem.title设置但不显示</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2017-01-27 00:00:00" itemprop="dateCreated datePublished" datetime="2017-01-27T00:00:00+08:00">2017-01-27</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">Edited on</span>
      <time title="Modified: 2018-07-01 16:06:22" itemprop="dateModified" datetime="2018-07-01T16:06:22+08:00">2018-07-01</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">In</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/iOS%E5%9F%BA%E7%A1%80/" itemprop="url" rel="index"><span itemprop="name">iOS基础</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h3 id="控制器结构图"><a href="#控制器结构图" class="headerlink" title="控制器结构图"></a>控制器结构图</h3><p><img src="http://ovsbvt5li.bkt.clouddn.com/18-1-27/84440891.jpg"><br>设置</p>
<blockquote>
<p>self.navigationItem.title &#x3D; “123”   </p>
</blockquote>
<p>运行，但设置的navigationItem.title并没有显示出来。    </p>
<h3 id="查找问题"><a href="#查找问题" class="headerlink" title="查找问题"></a>查找问题</h3><p>打开Debug View Hierarchy（视图层次结构调试），可以看到下面的结构图<br>左边：<br><img src="http://ovsbvt5li.bkt.clouddn.com/18-1-29/71287113.jpg"><br>右边：<br><img src="http://ovsbvt5li.bkt.clouddn.com/18-1-29/62998207.jpg"><br>可以看到总共有两个UINavgationBar,我们自己设置title并没有显示到顶层（被遮住了），所以会看不到设置的title。</p>
<h3 id="解决方法1"><a href="#解决方法1" class="headerlink" title="解决方法1"></a>解决方法1</h3><p>将第一个Navigation Controller删掉，Tab Bar Controller 直接作为根控制器，如下图：<br><img src="http://ovsbvt5li.bkt.clouddn.com/18-1-29/99794372.jpg"><br>还有其他的方法一样也是可以解决的。</p>

      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="https://vhuichen.github.io/2017/01/2017/01/%E4%BD%BF%E7%94%A8GitHub%20Desktop%20%E7%AE%A1%E7%90%86%E5%88%AB%E7%9A%84%E4%BB%93%E5%BA%93/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/vhuichen.jpg">
      <meta itemprop="name" content="vhuichen">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="vhuichen">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="undefined | vhuichen">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2017/01/2017/01/%E4%BD%BF%E7%94%A8GitHub%20Desktop%20%E7%AE%A1%E7%90%86%E5%88%AB%E7%9A%84%E4%BB%93%E5%BA%93/" class="post-title-link" itemprop="url">使用GitHub Desktop管理别的仓库</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2017-01-12 22:22:23" itemprop="dateCreated datePublished" datetime="2017-01-12T22:22:23+08:00">2017-01-12</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">Edited on</span>
      <time title="Modified: 2018-07-01 16:05:27" itemprop="dateModified" datetime="2018-07-01T16:05:27+08:00">2018-07-01</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">In</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/GitHub/" itemprop="url" rel="index"><span itemprop="name">GitHub</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h1 id="0-前言"><a href="#0-前言" class="headerlink" title="0.前言"></a>0.前言</h1><p>有些项目不想公开，但使用GitHub Desktop比较方便，于是尝试看看能否通过GitHub Desktop管理别的远程仓库，还好找到了，记下来。</p>
<h2 id="1-假设当前已经安装好GitHub-Desktop"><a href="#1-假设当前已经安装好GitHub-Desktop" class="headerlink" title="1.假设当前已经安装好GitHub Desktop"></a>1.假设当前已经安装好GitHub Desktop</h2><h2 id="2-以coding为例子，在coding上创建新的仓库"><a href="#2-以coding为例子，在coding上创建新的仓库" class="headerlink" title="2.以coding为例子，在coding上创建新的仓库"></a>2.以coding为例子，在coding上创建新的仓库</h2><h2 id="3-打开终端，cd到指定的目录。使用命令-git-clone-将远程仓库clone下来。"><a href="#3-打开终端，cd到指定的目录。使用命令-git-clone-将远程仓库clone下来。" class="headerlink" title="3.打开终端，cd到指定的目录。使用命令 git clone 将远程仓库clone下来。"></a>3.打开终端，cd到指定的目录。使用命令 git clone 将远程仓库clone下来。</h2><pre><code class="objc">git clone https://git.coding.net/xxxxxx/xxx.git
</code></pre>
<h2 id="4-打开GitHub-Desktop-点击右上角的“➕”号，选中add，Choose刚才clone的项目，确定。"><a href="#4-打开GitHub-Desktop-点击右上角的“➕”号，选中add，Choose刚才clone的项目，确定。" class="headerlink" title="4.打开GitHub Desktop 点击右上角的“➕”号，选中add，Choose刚才clone的项目，确定。"></a>4.打开GitHub Desktop 点击右上角的“➕”号，选中add，Choose刚才clone的项目，确定。</h2><h2 id="5-完成，至此可以通过GitHub-Desktop操作这个仓库了。"><a href="#5-完成，至此可以通过GitHub-Desktop操作这个仓库了。" class="headerlink" title="5.完成，至此可以通过GitHub Desktop操作这个仓库了。"></a>5.完成，至此可以通过GitHub Desktop操作这个仓库了。</h2>
      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="https://vhuichen.github.io/2016/11/2016/11/iOS%E5%9F%BA%E7%A1%80%E4%B9%8B%E8%AE%A1%E7%AE%97%E5%AD%97%E7%AC%A6%E4%B8%B2%E9%95%BF%E5%BA%A6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/vhuichen.jpg">
      <meta itemprop="name" content="vhuichen">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="vhuichen">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="undefined | vhuichen">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2016/11/2016/11/iOS%E5%9F%BA%E7%A1%80%E4%B9%8B%E8%AE%A1%E7%AE%97%E5%AD%97%E7%AC%A6%E4%B8%B2%E9%95%BF%E5%BA%A6/" class="post-title-link" itemprop="url">iOS基础之计算字符串长度</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2016-11-30 21:34:11" itemprop="dateCreated datePublished" datetime="2016-11-30T21:34:11+08:00">2016-11-30</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">Edited on</span>
      <time title="Modified: 2018-07-01 16:05:14" itemprop="dateModified" datetime="2018-07-01T16:05:14+08:00">2018-07-01</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">In</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/iOS%E5%9F%BA%E7%A1%80/" itemprop="url" rel="index"><span itemprop="name">iOS基础</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <p>创建NSString的分类，用来获取字符串的字节长度<br>用两种方法实现</p>
<figure class="highlight objc"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//</span></span><br><span class="line"><span class="comment">//  NSString+VCHProperty.h</span></span><br><span class="line"><span class="comment">//  SmartWatch</span></span><br><span class="line"><span class="comment">//</span></span><br><span class="line"><span class="comment">//  Created by chenhui on 2016/11/22.</span></span><br><span class="line"><span class="comment">//  Copyright © 2016年 vhuichen. All rights reserved.</span></span><br><span class="line"><span class="comment">//</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#import <span class="string">&lt;Foundation/Foundation.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">@interface</span> <span class="title">NSString</span> (<span class="title">VCHProperty</span>)</span></span><br><span class="line"></span><br><span class="line">- (<span class="built_in">NSUInteger</span>)convertToByteLength;</span><br><span class="line">- (<span class="built_in">NSUInteger</span>)asciiLength;</span><br><span class="line"></span><br><span class="line"><span class="keyword">@end</span></span><br></pre></td></tr></table></figure>

<p>实现方法</p>
<figure class="highlight objc"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//</span></span><br><span class="line"><span class="comment">//  NSString+VCHProperty.m</span></span><br><span class="line"><span class="comment">//  SmartWatch</span></span><br><span class="line"><span class="comment">//</span></span><br><span class="line"><span class="comment">//  Created by chenhui on 2016/11/22.</span></span><br><span class="line"><span class="comment">//  Copyright © 2016年 vhuichen. All rights reserved.</span></span><br><span class="line"><span class="comment">//</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#import <span class="string">&quot;NSString+VCHProperty.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">@implementation</span> <span class="title">NSString</span> (<span class="title">VCHProperty</span>)</span></span><br><span class="line"></span><br><span class="line">- (<span class="built_in">NSUInteger</span>)convertToByteLength &#123;</span><br><span class="line">    <span class="built_in">NSUInteger</span> selfLength = <span class="number">0</span>;</span><br><span class="line">    <span class="type">char</span> *p = (<span class="type">char</span> *)[<span class="keyword">self</span> cStringUsingEncoding:<span class="built_in">NSUnicodeStringEncoding</span>];</span><br><span class="line">    <span class="built_in">NSUInteger</span> encodingLength = [<span class="keyword">self</span> lengthOfBytesUsingEncoding:<span class="built_in">NSUnicodeStringEncoding</span>];</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">int</span> i = <span class="number">0</span>; i &lt; encodingLength; i++) &#123;</span><br><span class="line">        <span class="keyword">if</span> (*p) &#123;</span><br><span class="line">            selfLength++;</span><br><span class="line">        &#125;</span><br><span class="line">        p++;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> selfLength;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">- (<span class="built_in">NSUInteger</span>)asciiLength &#123;</span><br><span class="line">    <span class="built_in">NSUInteger</span> selflLength = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">int</span> i = <span class="number">0</span>; i &lt; <span class="keyword">self</span>.length; i++) &#123;</span><br><span class="line">        <span class="type">unichar</span> uc = [<span class="keyword">self</span> characterAtIndex:i];</span><br><span class="line">        selflLength += isascii(uc) ? <span class="number">1</span> : <span class="number">2</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> selflLength;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">@end</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>经测试两种方法都可以获取到字符串的字节长度</p>

      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




    


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
    <link itemprop="mainEntityOfPage" href="https://vhuichen.github.io/2016/11/2016/11/iOS%E5%9F%BA%E7%A1%80%E4%B9%8B%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8SVN%E6%9C%8D%E5%8A%A1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/vhuichen.jpg">
      <meta itemprop="name" content="vhuichen">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="vhuichen">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="undefined | vhuichen">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          <a href="/2016/11/2016/11/iOS%E5%9F%BA%E7%A1%80%E4%B9%8B%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8SVN%E6%9C%8D%E5%8A%A1/" class="post-title-link" itemprop="url">iOS基础之开机启动SVN服务</a>
        </h2>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2016-11-01 21:30:23" itemprop="dateCreated datePublished" datetime="2016-11-01T21:30:23+08:00">2016-11-01</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">Edited on</span>
      <time title="Modified: 2018-07-01 16:04:51" itemprop="dateModified" datetime="2018-07-01T16:04:51+08:00">2018-07-01</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">In</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/iOS%E5%9F%BA%E7%A1%80/" itemprop="url" rel="index"><span itemprop="name">iOS基础</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
          <h1 id="序言"><a href="#序言" class="headerlink" title="序言"></a>序言</h1><p>早前，上班时发现刚刚搭建好的本地SVN服务器无法连接 <strong>O(∩_∩)O~一脸懵逼</strong>，打开<code>活动监视器</code>发现SVN服务并没有自动开启，手动开启后发现还是不能连接，查看IP地址后才明白，IP是自动获取的啊，亲！so，先将IP改为手动分配，<strong>so easy</strong>。然后。。。。</p>
<h1 id="在命令行新建-sh文件"><a href="#在命令行新建-sh文件" class="headerlink" title="在命令行新建.sh文件"></a>在命令行新建.sh文件</h1><p>需要路径可以自己加上去</p>
<blockquote>
<p>vi SVNServe.sh  </p>
</blockquote>
<p>或者   </p>
<blockquote>
<p>touch SVNServe.sh</p>
</blockquote>
<h1 id="修改文件权限"><a href="#修改文件权限" class="headerlink" title="修改文件权限"></a>修改文件权限</h1><p>具体怎么改比较合适不清楚，反正直接<code>777</code>肯定没问题   </p>
<blockquote>
<p>chmod 777 SVNServe.sh</p>
</blockquote>
<h1 id="编辑-sh文件"><a href="#编辑-sh文件" class="headerlink" title="编辑.sh文件"></a>编辑.sh文件</h1><p>加入以下内容   </p>
<blockquote>
<p><strong>#!&#x2F;bin&#x2F;bash<br>svnserve -d -r ~&#x2F;svn</strong>   </p>
</blockquote>
<p><strong><code>#!/bin/bash</code></strong> 表示用根目录bin文件夹下的bash来解析这个脚本（bash是shell的一种）**<code>#!</code><strong>是特殊的表示符，据说一定要放在文件的第一行才起作用。</strong>不管，没试**。<br><strong><code>svnserve -d -r ~/svn</code></strong> 就是开启SVN服务器的命令，表示要执行这条指令。<br><code>~/svn</code>表示在用户根目录下<code>svn</code>这个文件夹下开启SVN服务</p>
<h1 id="添加自启动项"><a href="#添加自启动项" class="headerlink" title="添加自启动项"></a>添加自启动项</h1><blockquote>
<p>进入<code>系统偏好设置</code>-&gt;<code>用户与群组</code>-&gt;<code>登录项</code>，点击<code>+</code>号,添加上面编辑好的<code>.sh</code>文件。    </p>
</blockquote>
<p><strong><code>注意：不要在隐藏栏中打钩</code></strong><br><img src="https://github.com/vhuichen/image/blob/master/image/SVNAutoStart.png?raw=true" alt="Alt text">   </p>
<h1 id="以上"><a href="#以上" class="headerlink" title="以上"></a>以上</h1><p>搞定。。。。。。</p>
<p>#备注<br>将Mac的ID地址改为手动获取，防止下次开机IP地址改变</p>

      
    </div>

    
    
    

    <footer class="post-footer">
        <div class="post-eof"></div>
      
    </footer>
  </article>
</div>




  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/8/"><i class="fa fa-angle-left" aria-label="Previous page"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/8/">8</a><span class="page-number current">9</span><a class="page-number" href="/page/10/">10</a><a class="extend next" rel="next" href="/page/10/"><i class="fa fa-angle-right" aria-label="Next page"></i></a>
  </nav>

</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 2015 – 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">vhuichen</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/pisces/" rel="noopener" target="_blank">NexT.Pisces</a>
  </div>

    </div>
  </footer>

  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script>

  





  





</body>
</html>
